<template>
	<view class="container">
		<!-- 自定义导航栏 -->
		<uni-nav-bar left-icon="left" title="输入核销码" :border="false" background-color="#007AFF" color="#ffffff" :fixed="true" :statusBar="false" :rightWidth="120" @clickLeft="goBack">
			<template #right>
				<view class="nav-right">
					<uni-icons type="more-filled" size="22" color="#ffffff"></uni-icons>
					<uni-icons type="location-filled" size="22" color="#ffffff" style="margin-left: 10px;"></uni-icons>
				</view>
			</template>
		</uni-nav-bar>

		<!-- 固定输入区域 -->
		<view class="fixed-input-section">
			<view class="input-section">
				<view class="input-card">
					<text class="input-label">输入核销码</text>
					<input class="input-field" v-model="verifyCode" placeholder="请输入核销码" />
					<button class="recognize-btn" @click="handleRecognize">识别</button>
				</view>
			</view>
			<view class="code-display" v-if="verifyCode">
				核销码 {{ verifyCode }}
			</view>
		</view>

		<!-- 内容区域 -->
		<view class="content-wrapper">
			<!-- 服务内容 -->
			<view class="content-card" v-if="showContent">
				<view class="section-title">服务内容</view>
				<view class="service-content">
					<text class="service-title">XXX标准洗车服务包含</text>
					<view class="service-list">
						<text>整车泡沫冲洗擦洗</text>
						<text>轮胎轮毂冲洗清洁</text>
						<text>车内吸尘</text>
						<text>内饰脚垫简单除尘</text>
					</view>
					<text class="service-note">(不包含虫户、水泥、沥青和顽固污渍清理等)</text>
				</view>
			</view>

			<!-- 订单信息 -->
			<view class="content-card" v-if="showContent">
				<view class="section-title">订单信息</view>
				<view class="order-info">
					<view class="info-item">
						<text>订单价格:</text>
						<text>¥30.00</text>
					</view>
					<view class="info-item highlight">
						<text>实付金额:</text>
						<text>¥25.00</text>
					</view>
					<view class="info-item">
						<text>优惠金额:</text>
						<text>¥5.00</text>
					</view>
					<view class="info-item">
						<text>订单编号</text>
						<text>2020032554565799</text>
					</view>
					<view class="info-item">
						<text>支付时间</text>
						<text>2020.03.30 14:40:45</text>
					</view>
					<view class="info-item">
						<text>预约时间</text>
						<text>2020.03.30 14:40</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 确认核销按钮 -->
		<view class="bottom-btn-wrapper" v-if="showContent">
			<button class="confirm-btn" @click="goToVerifyOperation">确认核销</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				verifyCode: '',
				showContent: false
			}
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			handleRecognize() {
				if (!this.verifyCode) {
					uni.showToast({
						title: '请输入核销码',
						icon: 'none'
					})
					return
				}
				// 模拟识别核销码
				uni.showLoading({
					title: '识别中...'
				})
				setTimeout(() => {
					uni.hideLoading()
					this.showContent = true
					uni.showToast({
						title: '识别成功',
						icon: 'success'
					})
				}, 1000)
			},
			goToVerifyOperation() {
				if (!this.verifyCode) {
					uni.showToast({
						title: '请先识别核销码',
						icon: 'none'
					})
					return
				}
				uni.redirectTo({
					url: `/pages/verify-operation/verify-operation?code=${this.verifyCode}`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		min-height: 100vh;
		background-color: #f5f5f5;
		padding-bottom: 120rpx;
	}

	.nav-right {
		display: flex;
		align-items: center;
		padding-right: 20rpx;
	}

	/* 固定输入区域 */
	.fixed-input-section {
		position: fixed;
		top: 88rpx;
		left: 0;
		right: 0;
		width: 100%;
		z-index: 998;
		background-color: #ffffff;
		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
		box-sizing: border-box;
	}

	.input-section {
		padding: 20rpx 30rpx;
	}


	.input-card {
		display: flex;
		align-items: center;
		background-color: #f5f5f5;
		border-radius: 8rpx;
		padding: 24rpx 20rpx;
	}

	.input-label {
		font-size: 28rpx;
		color: #666;
		margin-right: 20rpx;
		min-width: 140rpx;
	}

	.input-field {
		flex: 1;
		font-size: 28rpx;
		color: #333;
		background-color: transparent;
	}

	.recognize-btn {
		background-color: #007AFF;
		color: #ffffff;
		border-radius: 8rpx;
		padding: 16rpx 32rpx;
		font-size: 28rpx;
		border: none;
		margin-left: 20rpx;
		line-height: 1;
		white-space: nowrap;
	}

	.code-display {
		padding: 20rpx 30rpx;
		font-size: 28rpx;
		color: #333;
		background-color: #f5f5f5;
	}

	/* 内容区域 */
	.content-wrapper {
		margin-top: 230rpx; /* 导航栏88rpx + 输入区域约142rpx */
		padding: 0 30rpx;
	}

	.content-card {
		background-color: #ffffff;
		border-radius: 0;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.section-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 24rpx;
	}

	.service-content {
		font-size: 28rpx;
		color: #333;
		line-height: 2;
	}

	.service-title {
		display: block;
		margin-bottom: 16rpx;
		color: #333;
	}

	.service-list {
		margin: 16rpx 0;
		text {
			display: block;
			margin-bottom: 12rpx;
			color: #333;
		}
	}

	.service-note {
		display: block;
		margin-top: 16rpx;
		color: #999;
		font-size: 24rpx;
		line-height: 1.6;
	}

	.order-info {
		font-size: 28rpx;
		color: #333;
	}

	.info-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;
		font-size: 28rpx;
		color: #333;

		&:last-child {
			margin-bottom: 0;
		}

		&.highlight {
			font-weight: bold;
			color: #333;
		}

		text:first-child {
			color: #666;
		}

		text:last-child {
			color: #333;
		}
	}

	.bottom-btn-wrapper {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		width: 100%;
		padding: 20rpx 30rpx;
		background-color: #ffffff;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.08);
		z-index: 999;
		box-sizing: border-box;
	}

	.confirm-btn {
		width: 100%;
		background-color: #007AFF;
		color: #ffffff;
		border-radius: 8rpx;
		padding: 28rpx 0;
		font-size: 32rpx;
		font-weight: 500;
		border: none;
		box-shadow: 0 2rpx 8rpx rgba(0, 122, 255, 0.3);
	}
</style>
